var array = [
  1,
  1,
  "1",
  "1",
  null,
  null,
  undefined,
  undefined,
  new String("1"),
  new String("1"),
  /a/,
  /a/,
  NaN,
  NaN,
];

// 利用set
let unique__1 = arr => [...new Set(arr)]
console.log(unique__1(array));

// filter
let unique__2 = arr => {
  let res = arr.filter((item, index, array) => {
    console.log('filter--', item, index);
    console.log('filter222--', array);
    console.log('filter333--', array.indexOf(item));
    return array.indexOf(item) === index
  })
  return res
}
console.log(unique__2(array));

// reduce
let unique__3 = arr => arr.reduce((pre, cur) => pre.includes(cur) ? pre : [...pre, cur], [])
console.log(unique__3(array));